<template>
	<view>
		<!--    TODO发布页-->
		<u-popup v-model="show" border-radius="59" length="60%" mode="bottom">
			<view class="popup">
				<text class="popup_title">{{ $t(fabu) }}</text>
				<view class="popup_body">
					<view @click="merchant">
						<image v-if="httpimgurl" :src="httpimgurl + '1_qiandan-11.png'"
							style="width: 141.28rpx;height: 139.53rpx">
						</image>
						<text>{{ $t('商家推广发布') }}</text>
					</view>
					<view @click="bidding">
						<image v-if="httpimgurl" :src="httpimgurl+'sannongzhengce.png'"
							style="width:137.79rpx ;height: 134.3rpx">
						</image>
						<text>{{ $t(jb) }}</text>
					</view>
				</view>
			</view>
		</u-popup>

		<!-- :mid-button="true" -->
		<!-- mid-button-size=80 -->
		<u-tabbar v-model="current" :before-switch="beforeSwitch" :list="tabBarItems" active-color="#767676"
			height="143rpx" ></u-tabbar>
	</view>
</template>

<script>
	import store from '@/store/index.js';
	import biddingTask from "@/pages/release/biddingTask/biddingTask.vue";
	// import {
	// 	mapGetters
	// } from 'vuex'
	import {
		HTTP_IMG_UTL
	} from "@/config/app"
	export default {
		data() {
			return {
				current: 3,
				show: false,
				show2: false,
				fabu: '发布信息',
				jb: "需求订单发布"
			};
		},

		created() {

		},
		props: {
			isShow: {
				default: false,
				type: Boolean
			}
		},
		watch: {
			isShow(newVal, oldVal) {
				this.show = oldVal
				if (this.show === false) {
					this.sonTOFather()
				}
			}
		},
		mounted() {
			const token = uni.getStorageSync('xzdToken');
			if (token) {
				this.$u.api.basic.getNoticeNum().then(res => {
					if (res) {
						store.commit('setMsgCount', res)
					}
				})
			}
			if (uni.getStorageSync('off') == false) {
				this.fabu = '发布信息'
				this.jb = '需求订单发布'
			} else {
				this.fabu = '发布信息'
				this.jb = '竞标任务发布'
			}
		},
		methods: {
			sonTOFather() {
				this.$emit("change", this.show)
			},
			beforeSwitch(index) {
				if (index === 2) {
					this.show = true
					return false
				}
				return true
			},
			//TODO发布
			merchant() {
				this.show = false
				this.$u.route({
					url: "/pages/release/merchantRelease/merchantRelease"
				})
			},
			bidding() {
				//竞标任务发布
				this.$u.route({
					url: "/pages/release/biddingTask/biddingTask"
				})
			}
		},
		computed: {
			httpimgurl() {
				return HTTP_IMG_UTL;
			},
			biddingTask() {
				return biddingTask
			},
			tabBarItems() {
				console.log('tabBarItems:',this.$store.state.tabBarItems);
				return this.$store.state.tabBarItems
			}
			// ...mapGetters([
			// 	'imMsgCount',
			// 	"sysMsgCount",
			// 	"otherMsgCount",
			// 	// ...
			// ])
		},
	}
</script>

<style lang="scss" scoped>
	.popup {
		display: flex;
		flex-direction: column;
		justify-content: center;

		.popup_title {
			text-align: center;
			font-size: 42rpx;
			font-weight: 600;
			color: #1F1F1F;
			line-height: 58rpx;
			margin-top: 66.48rpx;
			padding: 0 20rpx 0 20rpx;
		}

		.popup_body {
			display: flex;
			flex-direction: row;
			justify-content: space-evenly;

			view {
				margin-top: 83.72rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-between;
				font-size: 32rpx;
				font-weight: 400;
				color: #1F1F1F;
				line-height: 35rpx;
				width: 50%;

				text {
					margin-top: 20rpx;
					text-align: center;
					padding: 0 20rpx 0 20rpx;
				}
			}
		}


	}
</style>